<<<<<<< HEAD
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Ask extends CI_Controller {

    private $tab = 'system';

    function __construct() {
        parent::__construct();
        /** 登陆验证 */
        if (!isset($_SESSION)) {
            session_start();
        }
        $admin = $this->session->userdata('admin_user');
        if (!$admin || !isset($admin['user_id'])) {
            header('Location: /sys_admin/login');
            exit;
        }
    }

    /**
     * 获取安全问题列表数据
     * @param type $order
     */
    public function askList($sort = 'sort', $sortType = 'asc') {
        $this->load->model('Ask_Model', 'ask');
        $pageIndex = $this->input->get('per_page') ? $this->input->get('per_page') : 0;

        $vdata = $this->ask->orderBy(" $sort $sortType ")->get(array('isDel' => 0), $pageIndex);
        //分页
        $this->load->library('pagination');
        $config = array();
        $config['base_url'] = '/sys_admin/ask/asklist/?' . $sort;
        $config['total_rows'] = $vdata['count'];
        $config['per_page'] = sys_admin_LIST_PAGE_SIZE;
        $this->pagination->initialize($config);
        if ($sortType == 'asc') {
            $vdata['sortType'] = 'desc';
        } else {
            $vdata['sortType'] = 'asc';
        }


        $vdata['answerFormats'] = array(1 => '文本', 2 => '数字', 3 => '日期');

        $vdata['tab'] = $this->tab;
        $vdata['sub'] = 'safequestion';
        $this->load->view('/sys_admin/system/asklist', $vdata);
    }

    /**
     * 操作安全问题 增加/修改
     */
    public function getOne() {
        $id = $this->input->post("id");
        $vdata = array();
        $this->load->model('Ask_Model', 'ask');
        $vdata['askInfo'] = $this->ask->getOne($id);
        $vdata['ret'] = 1;
        echo json_encode($vdata);
    }

    /**
     * 修改问题数据
     */
    public function opAskSave() {
        $data = array();
        $data['id'] = (int) $this->input->post('id');
        $data['ask'] = $this->input->post('ask');
        $data['sort'] = (int) $this->input->post('sort');
        $data['answerFormat'] = $this->input->post('answerFormat');

        //保存
        $this->load->model('Ask_Model', 'ask');
        $this->ask->save($data);
        echo json_encode(array('msg' => '操作成功！'));
    }

    /**
     * 更改问题排序
     */
    public function opSort() {
        $data = array();
        $data['id'] = (int) $this->input->post('id');
        $data['sort'] = $this->input->post('sort');

        //保存
        $this->load->model('Ask_Model', 'ask');
        $this->ask->save($data);
        echo json_encode(array('msg' => '修改排序成功！'));
    }

    /**
     * 删除安全问题
     * @param int $id  安全问题ID
     */
    public function delAsk($id) {
        $this->load->model('Ask_Model', 'ask');
        $this->ask->delete($id);

        echo json_encode(array('msg' => '操作成功'));
    }

    /**
     * 暂停和激活
     * @param type $id
     */
    public function stopAndStart($id, $state) {
        $this->load->model('Ask_Model', 'ask');
        $this->ask->save(array('id' => $id, 'state' => $state));
        echo json_encode(array('msg' => '操作成功'));
    }

}
=======
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Ask extends CI_Controller {

    private $tab = 'system';

    function __construct() {
        parent::__construct();
        /** 登陆验证 */
        if (!isset($_SESSION)) {
            session_start();
        }
        $admin = $this->session->userdata('admin_user');
        if (!$admin || !isset($admin['user_id'])) {
            header('Location: /sys_admin/login');
            exit;
        }
    }

    /**
     * 获取安全问题列表数据
     * @param type $order
     */
    public function askList($sort = 'sort', $sortType = 'asc') {
        $this->load->model('Ask_Model', 'ask');
        $pageIndex = $this->input->get('per_page') ? $this->input->get('per_page') : 0;

        $vdata = $this->ask->orderBy(" $sort $sortType ")->get(array('isDel' => 0), $pageIndex);
        //分页
        $this->load->library('pagination');
        $config = array();
        $config['base_url'] = '/sys_admin/ask/asklist/?' . $sort;
        $config['total_rows'] = $vdata['count'];
        $config['per_page'] = sys_admin_LIST_PAGE_SIZE;
        $this->pagination->initialize($config);
        if ($sortType == 'asc') {
            $vdata['sortType'] = 'desc';
        } else {
            $vdata['sortType'] = 'asc';
        }


        $vdata['answerFormats'] = array(1 => '文本', 2 => '数字', 3 => '日期');

        $vdata['tab'] = $this->tab;
        $vdata['sub'] = 'safequestion';
        $this->load->view('/sys_admin/system/asklist', $vdata);
    }

    /**
     * 操作安全问题 增加/修改
     */
    public function getOne() {
        $id = $this->input->post("id");
        $vdata = array();
        $this->load->model('Ask_Model', 'ask');
        $vdata['askInfo'] = $this->ask->getOne($id);
        $vdata['ret'] = 1;
        echo json_encode($vdata);
    }

    /**
     * 修改问题数据
     */
    public function opAskSave() {
        $data = array();
        $data['id'] = (int) $this->input->post('id');
        $data['ask'] = $this->input->post('ask');
        $data['sort'] = (int) $this->input->post('sort');
        $data['answerFormat'] = $this->input->post('answerFormat');

        //保存
        $this->load->model('Ask_Model', 'ask');
        $this->ask->save($data);
        echo json_encode(array('msg' => '操作成功！'));
    }

    /**
     * 更改问题排序
     */
    public function opSort() {
        $data = array();
        $data['id'] = (int) $this->input->post('id');
        $data['sort'] = $this->input->post('sort');

        //保存
        $this->load->model('Ask_Model', 'ask');
        $this->ask->save($data);
        echo json_encode(array('msg' => '修改排序成功！'));
    }

    /**
     * 删除安全问题
     * @param int $id  安全问题ID
     */
    public function delAsk($id) {
        $this->load->model('Ask_Model', 'ask');
        $this->ask->delete($id);

        echo json_encode(array('msg' => '操作成功'));
    }

    /**
     * 暂停和激活
     * @param type $id
     */
    public function stopAndStart($id, $state) {
        $this->load->model('Ask_Model', 'ask');
        $this->ask->save(array('id' => $id, 'state' => $state));
        echo json_encode(array('msg' => '操作成功'));
    }

}
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
